Construct the pattern, using a nested for loopΒΆ
Construct the following pattern, using a nested for loop.
Expected output:
+
+ +
+ + +
+ + + +
+ + + + +
+ + + +
+ + +
+ +
+
N = 5
for i in range(N):
for j in range(i):
print ('+ ', end="")
print('')
for i in range(N, 0, -1):
for j in range(i):
print('+ ', end="")
print('')
Output:
*
* *
* * *
* * * *
* * * * *
* * * *
* * *
* *
*